<template>
	<div>
	<input type="text" class="inputset" v-model='value1' @blur='getTest($event)'/>
	<input type="text" class="inputset" v-model='value2' @blur='getTest($event)'/>
	</div>
</template>
<script>
	export default{
		name:'inputNumber',
		props:['model','other'],
		data(){
			return{
				value1:this.model,
				value2:this.other
			}
		},
		mounted(){
		},
		methods:{
			getTest(ev){
					ev.value = ev.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符  
				    ev.value = ev.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的  
				    ev.value = ev.value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); 
				    ev.value = ev.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数  
				    if(ev.value.indexOf(".")< 0 && ev.value !=""){//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额 
				        ev.value= parseFloat(ev.value); 
				    } 
				    ev.value = ev.value;
			}
		},
		watch:{
			/*value1(newVal){
				this.$emit('updata1',newVal);
			},
			value2(newVal){
				this.$emit('updata2',newVal);
			}*/
		}
	}
</script>
<style>
	.inputset{
		background:#e8e8e8;
		border:1px solid #c3c1c1;
		width:49px;
		height:21px;
		text-align: right;
	}
</style>